package com.zufe.khw;

import java.util.Arrays;

public class Demo1 {
    public static void main(String[] args) {
        GirdFriend g1 = new GirdFriend("xiaoshishi", 18, 1.68);
        GirdFriend g2 = new GirdFriend("xiaodandan", 19, 1.72);
        GirdFriend g3 = new GirdFriend("xiaobibi", 19, 1.72);
        GirdFriend[] gs = {g1, g2, g3};
        Arrays.sort(gs, (o1,o2) ->{
            double temp = o1.getAge() - o2.getAge();
            temp = temp == 0 ? o1.getHeight() - o2.getHeight() : temp;
            temp = temp == 0 ? o1.getName().compareTo(o2.getName()) : temp;
            if(temp > 0){
                return 1;
            }else if(temp < 0){
                return -1;
            }else{
                return 0;
            }
        });
        System.out.println(Arrays.toString(gs));
    }
}
